package org.red5.audio;

import java.io.File;

import org.red5.server.api.IScope;
import org.red5.server.api.stream.IStreamFilenameGenerator;

public class CustomFilenameGenerator implements IStreamFilenameGenerator {

    /** Path that will store recorded videos. */
    public String recordPath = "streams/";
    /** Path that contains VOD streams. */
    public String playbackPath = "streams/";
    
    public String generateFilename(IScope scope, String name,
            GenerationType type) {
        // Generate filename without an extension.
        return generateFilename(scope, name, null, type);
    }

    public String generateFilename(IScope scope, String name,
            String extension, GenerationType type) {
        String filename;
        if (type == GenerationType.RECORD)
            filename = recordPath + name;
        else
            filename = playbackPath + name;
        
        if (extension != null)
            // Add extension
            filename += extension;
        
        return filename;
    }

    public void setRecordPath(String path) {
        recordPath = path.replace("/", File.separator);
    }

    public void setPlaybackPath(String path) {
        playbackPath = path.replace("/", File.separator);
    }
    
	public boolean resolvesToAbsolutePath() {
		return false;
	}
}